﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Lossage.Net.Protocols.Modbus
{
    public enum DirectionType
    {
        Send = 0,
        Receive = 1,
    }

    public enum CommandType
    {
        ReadCoilStatus = 1, //00001
        ReadInputStatus = 2, //10001
        ReadHoldingRegisters = 3, //40001
        ReadInputRegisters = 4, //40001
        ForceSingleCoil = 5,
        PresetSingleRegister = 6,
        ForceMultipleCoils = 15,
        PresetMultipleRegisters = 16
    }
    public class ModbusModel
    {
        CommandType command;    //: "01",Y
        byte addr;             //: "03",Y
        UInt16 regNo;         //: "00 00",
        byte regLength;        //: "00 0a",
        byte bufferLen;        //: "0a",
        UInt16[] body;         //: "",

        public CommandType Command { get => command; set => command = value; }
        public byte Addr { get => addr; set => addr = value; }
        public ushort RegNo { get => regNo; set => regNo = value; }
        public byte RegLength { get => regLength; set => regLength = value; }
        public byte BufferLen { get => bufferLen; set => bufferLen = value; }
        public ushort[] Body { get => body; set => body = value; }
    }
}
